﻿namespace Z2.Editor
{

	using System;
	using System.Collections.Generic;
	using System.Text;
	using System.Xml;
	using System.Drawing;
	using System.IO;
	using System.Windows.Forms;

	public class EditorObject
	{

		private Bitmap m_bitmap;
		private ObjectType m_type;
		private string m_name;
		private string m_group;

		public EditorObject(string name, XmlNode node)
		{
			this.m_name = name;
			string file = string.Format("{0}.{1}", node.Attributes["Graphics"].Value, node.Attributes["Ext"].Value);
			this.m_bitmap = (Bitmap) Bitmap.FromFile(Path.Combine(Application.StartupPath, string.Format(@"Objects\{0}", file)));

			if (node.Name == "Object")
				this.m_type = ObjectType.Object;
			if (node.Name == "Env")
				this.m_type = ObjectType.Enviroment;
			this.m_group = node.Attributes["Group"] == null? null  :node.Attributes["Group"].Value;
		}

		public string Group
		{
			get
			{
				return this.m_group;
			}
		}

		public ObjectType Type
		{
			get
			{
				return this.m_type;
			}
		}

		public Bitmap Bitmap
		{
			get
			{
				return this.m_bitmap;
			}
		}

		public string Name
		{
			get
			{
				return this.m_name;
			}
		}
	}
}
